require "utils"

items = Item.find(:all)
items.each do |item|
  property_string = item.properties
  next if property_string.nil?
  next if property_string.empty?
  properties = property_string.split(",")
  new_properties = []
  same = true
  properties.each do |property_id|
    begin
      property = ItemProperty.find(property_id)
      next if property.nil?
      new_properties << property_id
    rescue
      same = false
    end
  end
  next if same
  item.properties = new_properties.join(",")
  item.save
end
